import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

public class MyGenericServlet extends GenericServlet {

    public void service(ServletRequest request, ServletResponse response)
            throws ServletException, IOException {
        //设置字符编码
        response.setCharacterEncoding("utf8");
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("<html><body>MyGenericServlet 响应</body></html>");
    }
}
